package com.xy.controller.mainData;

import com.xy.api.model.dto.mainData.LogisticalDTO;
import com.xy.api.model.request.mainData.LogisticalRequest;
import com.xy.api.model.response.R;
import com.xy.api.model.response.Rows;
import com.xy.api.service.mainData.ILogisticalService;
import com.xy.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/logistical")
public class LogisticalController extends BaseController {

    @Autowired
    private ILogisticalService logisticalService;

    @PostMapping("/queryList")
    public R queryLogisticalList(@RequestBody LogisticalRequest request) {
        Rows<LogisticalDTO> rows = logisticalService.queryLogisticalList(request);
        return success(rows);
    }

    @PostMapping("/queryAllList")
    public R queryAllLogisticalList() {
        Rows<LogisticalDTO> rows = logisticalService.queryAllLogisticalList();
        return success(rows);
    }

    @PostMapping("/detail")
    public R<LogisticalDTO> logisticalDetail(@RequestBody LogisticalRequest request) {
        LogisticalDTO logistical = logisticalService.logisticalDetail(request.getId());
        return success(logistical);
    }

    @PostMapping("/edit")
    public R<LogisticalDTO> editLogistical(@RequestBody LogisticalDTO request) {
        LogisticalDTO logistical = logisticalService.editLogistical(request);
        return success(logistical);
    }

    @PostMapping("/delete")
    public R deleteLogistical(@RequestBody LogisticalRequest request) {
        logisticalService.deleteLogistical(request.getId());
        return success();
    }
}
